"""MxOnline URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from  django.views.generic import TemplateView
from django.conf.urls import url,include
import xadmin
from django.views.static import serve

#函数方法登陆
#from users.views import user_login
#类方法登陆
from users.views import LoginView,LogoutView,RegisterView,ActiveUserView,ForgetPwdView,ResetView,ModifyPwdView
from  organization.views import OrgView
from users.views import IndexView,LoginUnsafeView
from MxOnline.settings import MEDIA_ROOT


urlpatterns = [
    path('xadmin/', xadmin.site.urls),
    url('^$',IndexView.as_view(),name="index"),
    #函数方法登陆使用的url，不需要带（）
    #url('^login/$', user_login, name="login")
    #类方法登陆使用的url,需要带（）
    url('^login/$', LoginView.as_view(), name="login"),

    # 含有sql注入的类方法登陆，实验用
    #url('^login/$', LoginUnsafeView.as_view(), name="login"),

    url('^logout/$', LogoutView.as_view(), name="logout"),
    url('^register/$', RegisterView.as_view(), name="register"),
    url('^captcha/', include('captcha.urls')),
    url('^active/(?P<active_code>.*)/$',ActiveUserView.as_view(),name="user_active"),
    url('^forget/$', ForgetPwdView.as_view(), name="forget_pwd"),
    url('^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"),
    url('^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"),


    # #课程机构
    # url('^org_list/$', OrgView.as_view(), name="org_list"),
    #课程机构分发处理
    url(r'^org/',include(('organization.urls','org'))),

    # 公开课分发处理
    url(r'^course/', include(('courses.urls', 'course'))),

    url('^media/(?P<path>.*)/$', serve,{"document_root":MEDIA_ROOT}),

    # 用户中心分发处理
    url(r'^users/', include(('users.urls', 'users'))),


    #富文本的引入
    url(r'^ueditor/', include(('DjangoUeditor.urls', 'ueditor'))),

]
